package interpreter.builtin.functions;

import interpreter.Callable;

import java.math.BigInteger;
import java.util.List;

import math.exact.Complex;

public class IntegerPredicate implements Callable {

	@Override
	public Object call(List<Object> arguments) {
		Object arg = arguments.get(0);
		if (arg instanceof Complex)
			return isInteger((Complex) arg);
		return false;
	}

	private Object isInteger(Complex exact) {
		return exact.getReal().getDenominator().equals(BigInteger.ONE)
				&& exact.getImag().getNumerator().equals(BigInteger.ZERO);
	}

}
